function Add-WindowsPowerShellFolder()
{
	$psUserPath = "C:\Users\$([Environment]::UserName)\Documents\WindowsPowerShell"
	if($(Test-Path $psUserPath) -eq $false)
	{
		New-Item -ItemType Directory -Force $psUserPath
	}

	$psUserModulePath="$($psUserPath)\Modules"
	if($(Test-Path $psUserModulePath) -eq $false)
	{
		New-Item -ItemType Directory -Force $psUserModulePath
	}
}

function Add-ModuleFolder($ModuleName)
{
	$psUserModulePath = "C:\Users\$([Environment]::UserName)\Documents\WindowsPowerShell\Modules"

	$psModulePath="$($psUserModulePath)\$($moduleName)"
	if($(Test-Path $psModulePath) -eq $false)
	{
		New-Item -ItemType Directory -Force $psModulePath
	}
}

function Install-MyModule()
{
	[CmdletBinding()]
	param(
		[Parameter( Mandatory=$true,
					ValueFromPipeline=$false,
					ValueFromPipelineByPropertyName=$false,
					HelpMessage="Module Name"
		)]
		[string] $ModuleName,
		[Parameter( Mandatory=$true,
					ValueFromPipeline=$false,
					ValueFromPipelineByPropertyName=$false,
					HelpMessage="File to deploy"
		)]
		[string[]] $Files,
		[switch] $Replace
	)
	begin
	{
		# Validate the PS folder exists
		Add-WindowsPowerShellFolder

		#Set the path to the users modules folder
		$psUserModulePath = "C:\Users\$([Environment]::UserName)\Documents\WindowsPowerShell\Modules"

		# Add a new folder for the module name being installed
		Add-ModuleFolder -ModuleName $ModuleName

		# Set the path to the users module folder including the modulepath
		$psModulePath="$($psUserModulePath)\$($ModuleName)"

		# If the user passed the -Replace switch delete all files from the target folder
		if($Replace -eq $true)
		{
			Remove-Item "$psmodulePath\*.*" -Force -Recurse
		}
	}

	process
	{
		foreach($file in $Files)
		{
			Copy-Item $file `
					  $psModulePath `
					  -Force
		}
	}
}